﻿using AdinZ.Web.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
/**
* @Author: AdinZ
* @Q  Q : 1454269
* @Email:adinz@adinz.com
* @Created: 2014/4/1 21:14:48
* */
namespace Web.admin
{
    public partial class chapter : Admin_BasePage
    {
        private int vPage=1;
        protected int vID;
        private string vSQL;
        protected int chapterCount = 0;

        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.QueryString["ID"] != null && Request.QueryString["ID"].Trim() != "")
            {
                if (!int.TryParse(Request.QueryString["ID"], out vID))
                {
                    Response.Write("ID Error");
                    Response.End();
                }
            }
            else
            {
                Response.Write("ID Error");
                Response.End();
            }

            if (Request.QueryString["Page"] != null && Request.QueryString["Page"].Trim() != "")
            {
                if (!int.TryParse(Request.QueryString["Page"], out vPage))
                {
                    vPage = 1;
                }
            }
            vSQL = "1=1";
            if (vID > 0) { vSQL += " AND [aid]='" + vID + "'"; }
            getPageList();

        }



        protected void getPageList()
        {
            int vPageSize = 10;
            int vRecordCount = __bll_chap.GetCount(vSQL);
            chapterCount = vRecordCount;
            repRecordList.DataSource = __bll_chap.GetListByPage(vSQL, "  chapternum asc  ", (vPage - 1) * vPageSize, vPage * vPageSize);
            repRecordList.DataBind();
            string pTemp = "";
            int vPageCount = 1;
            if (vRecordCount > 0)
            {
                vPageCount = (int)Math.Ceiling((double)vRecordCount / (double)vPageSize);
                pTemp = PageList.GetPagingInfo_Manage(vPageCount, vRecordCount, vPage, vPageSize);
            }

            this.pagelist.InnerHtml = pTemp;
        }
    }
}